
import pymysql
from pymysql.cursors import SSDictCursor

class mysqldb():
    def __init__(self):  # 连接数据库
        self.con = pymysql.connect(host='10.10.10.174', user='root', password='123456', database='woniuboss', port=3306)
        self.cursor = self.con.cursor(SSDictCursor)

    def excute_sql(self,sql):

        self.cursor.execute(sql)

    def read_data(self):
        sql = """
        select * from woniuboss_01
        """
        self.cursor.execute(sql)
        result_list = []
        for result in self.cursor.fetchall():
            result_list.append(result)

        return result_list[::-1]

    def __del__(self):
        self.con.autocommit(True)
        self.cursor.close()
        self.con.close()

if __name__ == '__main__':
    db = mysqldb()
    a =db.read_data()
    print(a)